Skip to content

[ThienDuc3112] iP#100

Open
ThienDuc3112 wants to merge 24 commits into
nus-cs2113-AY2425S1:masterfrom
ThienDuc3112:master
Open

[ThienDuc3112] iP#100
ThienDuc3112 wants to merge 24 commits into
nus-cs2113-AY2425S1:masterfrom
ThienDuc3112:master

Conversation

@ThienDuc3112

Copy link
Copy Markdown

No description provided.

Comment thread src/main/java/DBot.java Outdated
@@ -0,0 +1,111 @@
import java.util.*;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using wildcard imports
Import only the functions that you need

Comment thread src/main/java/DBot.java Outdated
isOn = true;
datas = new ArrayList<>();

String greeting = "____________________________________________________________\n" +

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "final" and SCREAMING_SNAKE_CASE for the greeting variable as it is a constant

Comment thread src/main/java/Task.java Outdated
return isDone;
}

public void mark(){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a space before the "{" to keep layout consistent

Comment thread src/main/java/DBot.java Outdated
String line = in.nextLine().strip();
System.out.println("____________________________________________________________");

if (line.equals("bye")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed if else layout convention. Good job

@seanngja seanngja left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread src/main/java/DBot.java Outdated
@@ -0,0 +1,111 @@
import java.util.*;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could import just the libraries you need?

Comment thread src/main/java/DBot.java Outdated
Comment on lines +26 to +40
} else if (line.equals("list")) {
list();
} else if (line.startsWith("mark ")) {
mark(line);
} else if (line.startsWith("unmark ")) {
unmark(line);
} else if (line.startsWith("todo ")) {
todo(line);
} else if (line.startsWith("event ")) {
event(line);
} else if (line.startsWith("deadline ")) {
deadline(line);
} else {
add(line);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could refactor this into another function? This chunk is long and hard to read.

Comment thread src/main/java/DBot.java Outdated

private static void todo(String line) {
String todo = line.substring(line.indexOf(" ") + 1).trim();
Todo task =new Todo(todo);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the formatting after the = sign.

Comment thread src/main/java/DBot.java Outdated

public static void main(String[] args) {
isOn = true;
datas = new ArrayList<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could use a more descriptive name for your array list, as it is unclear what is being stored here.

Comment thread src/main/java/Task.java
Comment on lines +30 to +33
return "[" +
(isDone ? "X" : " ") +
"] " +
task;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you could write this all in 1 line of code to make your code more readable.

@Mahesh1772 Mahesh1772 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid effort

Code is following most of the code quality standards. The naming would need to be improved for better scalability so that fellow developers can understand the use of the method and variable easily. Consider adding JavaDocs in future commits

Comment thread src/main/java/DBot.java
private static List<Task> taskList;

public static void main(String[] args) {
isOn = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using more descriptive names, that is easily identified to serve a definite purpose

Comment thread src/main/java/DBot.java Outdated
Comment on lines +27 to +42
isOn = false;
} else if (line.equals("list")) {
list();
} else if (line.startsWith("mark ")) {
mark(line);
} else if (line.startsWith("unmark ")) {
unmark(line);
} else if (line.startsWith("todo ")) {
todo(line);
} else if (line.startsWith("event ")) {
event(line);
} else if (line.startsWith("deadline ")) {
deadline(line);
} else {
System.out.println("Unknown command: " + line);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using switch case for this case, as the different cases of input is pre-determined

Comment thread src/main/java/DBot.java
}
}

private static void list() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider naming it as listTasks to avoid confusion with the inbuilt type

Comment thread src/main/java/DBot.java Outdated
Comment on lines +57 to +74
int option = Integer.parseInt(line.substring(line.indexOf(" ") + 1));
System.out.println("Nice! I've marked this task as done:");
taskList.get(option - 1).mark();
System.out.println(taskList.get(option - 1).toString());
} catch (Exception e) {
System.out.println("Invalid input, input must be a positive integer and must exist");
}
}

private static void unmark(String line) {
try {
int option = Integer.parseInt(line.substring(line.indexOf(" ") + 1));
System.out.println("OK, I've marked this task as not done yet:");
taskList.get(option - 1).unmark();
System.out.println(taskList.get(option - 1).toString());
} catch (Exception e) {
System.out.println("Invalid input, input must be a positive integer and must exist");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using the same method or a central part for both functions as to reduce the number of duplicate lines of code

Comment thread src/main/java/DBot.java Outdated
System.out.println("Now you have " + taskList.size() + " tasks in the list.");
}

private static void event(String line) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider naming the methods better for easy maintainability and scalability

Comment thread src/main/java/Event.java
Comment on lines +2 to +3
String from;
String to;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider something like fromDate , toDate

Comment thread src/main/java/Task.java
Comment on lines +31 to +34
return "[" +
(isDone ? "X" : " ") +
"] " +
task;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider same line implementation to increase code readability

Comment thread src/main/java/Utilities.java Outdated

public class Utilities {
public static Hashtable<String, String> getCommandArgument(String line) {
Hashtable<String, String> args = new Hashtable<>();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to not use vague names for variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants